﻿using UnityEngine;

namespace Controller{
	public sealed class ControllerManager : MonoBehaviour {

		public ControllerButton leftButton,rightButton,upButton,downButton,startButton,cancleButton;

		/// <summary>
		/// Sets the arrow pressed event. while replace other event
		/// </summary>
		/// <param name="left">Left.</param>
		/// <param name="right">Right.</param>
		/// <param name="top">Top.</param>
		/// <param name="bottom">Bottom.</param>
		public void SetArrowPressedEvent(ControllerButton.ButtonEvent left,ControllerButton.ButtonEvent right,ControllerButton.ButtonEvent up,ControllerButton.ButtonEvent down){
			if(null != left && leftButton)
				leftButton.pressedEvent = left;
			if(null != right && rightButton)
				rightButton.pressedEvent = right;
			if(null != up && upButton)
				upButton.pressedEvent = up;
			if(null != down && downButton)
				downButton.pressedEvent = down;
		}
		/// <summary>
		/// Adds the arrow pressed event.not replace other event
		/// </summary>
		/// <param name="left">Left.</param>
		/// <param name="right">Right.</param>
		/// <param name="top">Top.</param>
		/// <param name="bottom">Bottom.</param>
		public void AddArrowPressedEvent(ControllerButton.ButtonEvent left,ControllerButton.ButtonEvent right,ControllerButton.ButtonEvent up,ControllerButton.ButtonEvent down){
			if(null != left && leftButton)
				leftButton.pressedEvent += left;
			if(null != right && rightButton)
				rightButton.pressedEvent += right;
			if(null != up && upButton)
				upButton.pressedEvent += up;
			if(null != down && downButton)
				downButton.pressedEvent += down;
		}
		/// <summary>
		/// Set the start and cancel button click event.
		/// </summary>
		/// <param name="start">Start.</param>
		/// <param name="cancle">Cancle.</param>
		public void SetStartAndCancelClickEvent(ControllerButton.ButtonEvent start,ControllerButton.ButtonEvent cancle){
			if(null != start && startButton)
				startButton.onClickEvent = start;
			if(null != cancle && startButton)
				cancleButton.onClickEvent = cancle;
		}
		/// <summary>
		/// Add the start and cancel click event.
		/// </summary>
		/// <param name="start">Start.</param>
		/// <param name="cancle">Cancle.</param>
		public void AddStartAndCancelClickEvent(ControllerButton.ButtonEvent start,ControllerButton.ButtonEvent cancle){
			if(null != start && startButton)
				startButton.onClickEvent += start;
			if(null != cancle && startButton)
				cancleButton.onClickEvent += cancle;
		}
	}
}
